<script>

	chrome.windows.getCurrent(function(window) 
	{ 
		chrome.tabs.getSelected(window.id, function(tab)
		{
			chrome.tabs.sendRequest(tab.id, {action: "get_text"}, function(response)
			{
				writeQRCode(response.text);
			});
		});
	});

/*
	chrome.windows.getCurrent(function(window) 
	{ 
		chrome.tabs.getSelected(window.id, function(tab) 
		{
			writeQRCode(tab.url);
		});
	});
*/
	
	function writeQRCode(text)
	{
		var escaped = escape(text);
		escaped = escaped.replace(/[+]/g, '%2B');
		document.write('<img src="http://qrcode.kaywa.com/img.php?s=4&d=' +
			 escaped + '" alt="qrcode" />');
	}

</script>
